#include<iostream>
#define M 100
#define N 100
using namespace std;
int a[M][N] = { 0 };
 
 
void fun(int n,int s)
{
	
	int k = 0;    //标记
	int i = 0, j = 0;
	int m = 1;
		a[0][0] = m;
	while (m < n*s)
	{
		switch (k)
		{
		case 0:       //向右或向下
			if (i + j < s - 1 )a[i][++ j] = ++ m;
			else a[++ i][j] = ++ m;
			k = (k + 1) % 4;
			break;
		case 1:           //向左下
			while (i< n -1 && j> 0)a[ ++ i][ -- j] = ++ m;
			k = (k + 1) % 4;
			break;
		case 2:       //向下或向右
			if (i + j < n - 1)a[ ++ i][j] = ++ m;
			else a[i][ ++ j] = ++ m;
			k = (k + 1) % 4;
			break;
		case 3:        //向右上
			while (i > 0 && j < s - 1)a[ -- i][ ++ j] = ++ m;
			k = (k + 1) % 4;
			break;
		}
	}
 
}
void display(int n,int s)
{
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j < s; j++)
			printf("%5d", a[i][j]);
		cout << endl;
	}
}
 
int main()
{
 
	int n,s;
	cin >> n >> s;
	fun(n,s);
	display(n,s);
}